﻿@model InVision_Ticket.Models.CustomerViewModel

@{
    ViewBag.Title = "Edit";
}
<h2>Edit</h2>
<script>
	$(function () {
		$('#BusinessCheckBox').change(function () {
			if ($(this).is(':checked')) {
				document.getElementById('BusinessNameLabel').style.display = 'block';
				document.getElementById('BusinessNameEditor').style.display = 'block';
			} else {
				document.getElementById('CustomerName').value = '';
				document.getElementById('BusinessNameLabel').style.display = 'none';
				document.getElementById('BusinessNameEditor').style.display = 'none';
			}
		});
	});
	function load() {
		if ($(this).is(':checked')) {
			document.getElementById('BusinessNameLabel').style.display = 'block';
			document.getElementById('BusinessNameEditor').style.display = 'block';
		} else {
			document.getElementById('CustomerName').value = '';
			document.getElementById('BusinessNameLabel').style.display = 'none';
			document.getElementById('BusinessNameEditor').style.display = 'none';
		}
	}
</script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>CustomerViewModel</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.BusinessCustomer)
        </div>
        <div class="editor-field">
            @Html.CheckBoxFor(model => model.BusinessCustomer, new { id = "BusinessCheckBox" })
            @Html.ValidationMessageFor(model => model.BusinessCustomer) 
        </div>
		
		<div id="BusinessNameLabel" class="editor-label">
			@Html.LabelFor(model => model.CustomerName)
		</div>
		<div id="BusinessNameEditor" class="editor-field">
			@Html.EditorFor(model => model.CustomerName)
			@Html.ValidationMessageFor(model => model.CustomerName)
		</div>


        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PhoneString)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PhoneString)
            @Html.ValidationMessageFor(model => model.PhoneString)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address1)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address1)
            @Html.ValidationMessageFor(model => model.Address1)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address2)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address2)
            @Html.ValidationMessageFor(model => model.Address2)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.City)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.City)
            @Html.ValidationMessageFor(model => model.City)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.State)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.State)
            @Html.ValidationMessageFor(model => model.State)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Zip)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Zip)
            @Html.ValidationMessageFor(model => model.Zip)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PromotionalEmails)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PromotionalEmails)
            @Html.ValidationMessageFor(model => model.PromotionalEmails)
        </div>
		<div class="editor-label">
            @Html.LabelFor(model => model.CustomerNotes)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.CustomerNotes)
            @Html.ValidationMessageFor(model => model.CustomerNotes)
        </div>

        <div class="editor-field" id="CustomerContactIDDiv">
            @Html.TextBoxFor(model => model.CustomerContactID, new { style = "display:none;", @readonly = "readonly" })
        </div>

        <div class="editor-field" id="CustomerIDDiv">
            @Html.TextBoxFor(model => model.CustomerID, new { style = "display:none;", @readonly = "readonly" })
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
